package com.mind.adjust.domain.webservice.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlElement;
import java.util.HashMap;
import java.util.Map;

@Data
public class Response {
    @JsonProperty("Head")
    private Head head;
    @JsonProperty("Data")
    private Map<String, Object> data = new HashMap<>();

    // Head类
    @Data
    public static class Head {
        @JsonProperty("BIZTRANSACTIONID")
        private String bizTransactionId;
        @JsonProperty("RESULT")
        private String result;
        @JsonProperty("ERRORCODE")
        private String errorCode;
        @JsonProperty("ERRORINFO")
        private String errorInfo;
        @JsonProperty("COMMENTS")
        private String comments;
        @JsonProperty("SUCCESSCOUNT")
        private String successCount;

        // 省略getter和setter方法
    }

    // 省略getter和setter方法

    public static Response createResponse(String bizTransactionId, String result, String errorCode, String errorInfo, String comments) {
        Response response = new Response();
        response.setHead(new Head());
        response.getHead().setBizTransactionId(bizTransactionId);
        response.getHead().setResult(result);
        response.getHead().setErrorCode(errorCode);
        response.getHead().setErrorInfo(errorInfo);
        response.getHead().setComments(comments);
        response.getHead().setSuccessCount(""); // 根据需要设置成功计数

        // 根据需要填充data
        // response.getData().put("key", value);

        return response;
    }

    public static Response createResponse(String result, String errorCode, String errorInfo){
        return createResponse("", result, errorCode, errorInfo, "");
    }

    public static Response createResponse(String bizTransactionId, String result, String errorCode, String errorInfo){
        return createResponse(bizTransactionId, result, errorCode, errorInfo, "");
    }
}
